package com.mark.mall.web.platform.myMethod;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.mark.mall.common.constans.PlatformConstant;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author admin
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
       System.out.println("自动填充字段 state createtime ------");
       setFieldValByName("state", PlatformConstant.STATE_YES, metaObject);
       setFieldValByName("createtime", LocalDateTime.now(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
